#include <iostream>
#include <random>
#include <ctime>
#include "test.h"
using namespace std;

void update(int arr[8][8])
{
    int arrx1[8];
    int arrx2[8];
    int arrx3[8];
    int arrx4[8];
    int arrx5[8];
    int arrx6[8];
    int arrx7[8];
    int arrx8[8];
    int arry1[8];
    int arry2[8];
    int arry3[8];
    int arry4[8];
    int arry5[8];
    int arry6[8];
    int arry7[8];
    int arry8[8];
    for(int i=0;i<8;i++)
    {
        arrx1[i]=arr[0][i];
        arrx2[i]=arr[1][i];
        arrx3[i]=arr[2][i];
        arrx4[i]=arr[3][i];
        arrx5[i]=arr[4][i];
        arrx6[i]=arr[5][i];
        arrx7[i]=arr[6][i];
        arrx8[i]=arr[7][i];
        arry1[i]=arr[i][0];
        arry2[i]=arr[i][1];
        arry3[i]=arr[i][2];
        arry4[i]=arr[i][3];
        arry5[i]=arr[i][4];
        arry6[i]=arr[i][5];
        arry7[i]=arr[i][6];
        arry8[i]=arr[i][7];
    }
    BejSolve(arrx1);
    BejSolve(arrx2);
    BejSolve(arrx3);
    BejSolve(arrx4);
    BejSolve(arrx5);
    BejSolve(arrx6);
    BejSolve(arrx7);
    BejSolve(arrx8);
    BejSolve(arry1);
    BejSolve(arry2);
    BejSolve(arry3);
    BejSolve(arry4);
    BejSolve(arry5);
    BejSolve(arry6);
    BejSolve(arry7);
    BejSolve(arry8);
    for(int i=0;i<8;i++)
    {
        arr[0][i]=arrx1[i];
        arr[1][i]=arrx2[i];
        arr[2][i]=arrx3[i];
        arr[3][i]=arrx4[i];
        arr[4][i]=arrx5[i];
        arr[5][i]=arrx6[i];
        arr[6][i]=arrx7[i];
        arr[7][i]=arrx8[i];
    }


    cout<<"After update:"<<endl;
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
}


int main()
{
    default_random_engine generator(114);
    uniform_int_distribution<int> distribution(1, 4);
    int arr[8][8];
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        {
            arr[i][j]= distribution(generator);
            cout<<arr[i][j]<<" ";
        }
        cout<<endl;
    }
    update(arr);
    return 0;
}